package com.masterclient.app.modules.aftersale.adapter;

import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.masterclient.app.R;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

/**
 * 作者：Hxm
 * 创建时间：2019/12/23
 * 功能说明：
 */

public class MaterialImageAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private int width ,radius;
    public MaterialImageAdapter(int width ) {
        super(R.layout.item_material_image);
        this.width = width;
        radius = 7;
    }
    public MaterialImageAdapter(int width, int radius ) {
        super(R.layout.item_material_image);
        this.width = width;
        this.radius = radius;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        ImageView imageView = helper.getView(R.id.item_material_image);
        imageView.getLayoutParams().width = width;
        imageView.getLayoutParams().height = width;
        ViewTransformUtil.glideImageView(mContext,item,imageView,
                new Transformation[]{new CenterCrop(),new RoundedCornersTransformation(ScreenUtils.dp2px(radius)
                        ,0)}, TextUtils.isEmpty(item)?R.color.transparent:R.color.gray_line);

    }
}
